/*
 * Copyright (c) 2006 - 2022, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.concurrent.TimeUnit;

/**
 * <p>Project: app2022 - T21
 * <p>Powered by webrx On 2022-02-07 15:54:51
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class T21 {
    public static void main(String[] args) throws InterruptedException {

        var t1 = new Thread(() -> {
            String tn = Thread.currentThread().getName();
            for (int i = 0; i < 5; i++) {
                try {
                    TimeUnit.SECONDS.sleep(2);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                System.out.printf("%s:%d%n", tn, i);
            }
        }, "T1");
        t1.start();
        //t1.join();

        var t2 = new Thread(() -> {
            String tn = Thread.currentThread().getName();
            for (int i = 0; i < 5; i++) {
                try {
                    TimeUnit.SECONDS.sleep(1);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                System.out.printf("%s:%d%n", tn, i);
            }
        }, "T2");

        t2.start();
        //t2.join();


        String tn = Thread.currentThread().getName();
        for (int i = 0; i < 5; i++) {
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.printf("%s:%d%n", tn, i);
        }
    }
}
